package com.sita.redsun.connector.startup;

import com.sita.redsun.connector.server.ServerBase;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;

/**
 * Created by zhebinwang on 2017/3/28.
 */
@Order(1)
public class StartManager  extends AbstractAnnotationConfigDispatcherServletInitializer {


    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        super.onStartup(servletContext);
    }

    @Override
    protected Class<?>[] getRootConfigClasses() {

        ServerBase serverBase=new ServerBase();
        serverBase.init();
        serverBase.doStart();
        System.out.println("启动5");

        //初始化MQ的发送和接收模块，主要是为了初始化连接
        //MQSender mqSender=new MQSender();
        //MQReciver mqReciver=new MQReciver();



/*
        try {
            mqReciver.init();
        } catch (Exception e) {
            e.printStackTrace();
        }*/

     /*   try {
            mqSender.init();
        } catch (JMSException e) {
            e.printStackTrace();
        }*/

        //初始化MQ接收模块，主要是初始化pool对象，多线程
        //MQReciveListener mqReciveListener =new MQReciveListener();
        //mqReciveListener.init();
        //return new Class<?>[]{ConfigBegin.class};
        return new Class<?>[]{ConfigBegin.class,AppInit.class};
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class<?>[0];
    }

    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}
